/**
 * 1967. 作为子字符串出现在单词中的字符串数目
 * https://leetcode-cn.com/problems/number-of-strings-that-appear-as-substrings-in-word/
 */
public class Solutions_1967 {
    public static void main(String[] args) {
//        String[] patterns = {"a", "abc", "bc", "d"};
//        String word = "abc";  // output: 3

//        String[] patterns = {"a", "b", "c"};
//        String word = "aaaaabbbbb";  // output: 2

        String[] patterns = {"a", "a", "a"};
        String word = "ab";  // output: 3

        int result = numOfStrings(patterns, word);
        System.out.println(result);
    }

    public static int numOfStrings(String[] patterns, String word) {
        int res = 0;
        for (String pattern : patterns) {
            if (word.indexOf(pattern) != -1) {
                res ++;
            }
        }
        return res;
    }
}
